# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Ray Rashif <schiv@archlinux.org>
# Contributor: speps <speps at aur dot archlinux dot org>

pkgbase=sratom
pkgname=(sratom sratom-docs)
pkgver=0.6.14
pkgrel=1
pkgdesc="An LV2 Atom RDF serialisation library"
arch=(loong64 x86_64)
url="https://drobilla.net/software/sratom.html"
license=(ISC)
makedepends=(doxygen lv2 meson python-sphinx python-sphinx-lv2-theme serd sord)
options=(debug)
source=(https://download.drobilla.net/$pkgname-$pkgver.tar.xz{,.sig})
sha512sums=('3647ccca3ac98299a0bcc30d540788c627445c9a55f0b68a53e08ee45b15138c7a5466c92d1c10eac614325718d4f59eff6f0664f99891e8349e613be675c87d'
            'SKIP')
b2sums=('6f468e9a0de97cf83a4f3faeb8ceff8a5502da7f0dff6b5721ef985df352057cda0dbbf13656471ef7f3103a891570e3462ed6bf4517dbc546d9f83115db433b'
        'SKIP')
validpgpkeys=('907D226E7E13FA337F014A083672782A9BF368F3') # David Robillard <d@drobilla.net>

_pick() {
  local p="$1" f d; shift
  for f; do
    d="$srcdir/$p/${f#$pkgdir/}"
    mkdir -p "$(dirname "$d")"
    mv "$f" "$d"
    rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
  done
}

build() {
  arch-meson $pkgname-$pkgver build
  meson compile -C build
}

check() {
  meson test -C build
}


package_sratom() {
  depends=(glibc libserd-0.so libsord-0.so lv2)
  provides=(libsratom-0.so)
  optdepends=('sratom-docs: for developer documentation')

  meson install -C build --destdir "$pkgdir"
  (
    cd "$pkgdir"
    _pick $pkgname-docs usr/share/doc
  )
  install -vDm 644 $pkgname-$pkgver/COPYING -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 $pkgname-$pkgver/{NEWS,README.md} -t "$pkgdir/usr/share/doc/$pkgname/"
}

package_sratom-docs() {
  pkgdesc+=" - documentation"

  mv -v $pkgname/* "$pkgdir"
  mv -v "$pkgdir/usr/share/doc/"sratom{-0,}
}
